The Format event for the Section object

The Crystal Report Designer Component provides a Format event for every section of your report. This allows you to control report formatting and output dynamically at runtime. For example, you can apply conditional formatting during the Format event, based on conditions that exist only at runtime.

The Format event is a standard Visual Basic event that you can program by displaying the Code View of the Report Designer Component. Assuming the Report Designer has been named CrystalReport1 in your Visual Basic project:

  1. In the Visual Basic Project window, select the CrystalReport1 designer from the Designers folder.
  2. Click the View Code button in the toolbar at the top of the Project window. A Code window will appear for the CrystalReport1 designer component.
  3. In the object drop-down list box at the top left of the Code window, select a Section object that you want to apply code to. Notice that Section objects are numbered in the order that they appear on your report, from the top of the Report Design window to the bottom. For instance, if you select the Section1 object, your code will apply to the Report Header section of your report. These Section objects are labeled for you at the top of each section in the Report Designer window.

Notice that when you select a Section object, the Format event is automatically selected for you in the event drop-down list box at the top right of the Code window. Format is the only event available to the Section object.

When writing code for the Format event, keep in mind that not all properties and methods for all objects are available during the Format event. Many properties are available on a read-only basis. If you are not sure about a property or method, refer to the specific property or method name in the Object Browser or the Report Designer Object Model reference section of the Crystal Reports Developer's Help (CrystalDevHelp.chm) and the Report Designer Component Help (Crrdc.hlp).

The Format event receives a single argument from the Report Designer Component. The pFormattingInfo argument is an object of type FormattingInfo. The FormattingInfo object has only three properties:

Note:    When designing your application, be aware that when a section is being formatted, all objects in that section are also being formatted. Also, all other sections and objects outside of the current section are not being formatted. This information can affect how data is displayed in various sections of the report, depending on your code.

Note:    If you are using the Format event to calculate values and you need to carry that value across sections (as in a running total, for example), you will need to use a Report Variable to store your ongoing total. Report Variables are new to Crystal Reports. For further information on Report Variables, please see Report Variables.



Seagate Software IMG Holdings, Inc.
http://www.seagatesoftware.com
Support services:
http://support.seagatesoftware.com